Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | const { Guard } = require('./guard'); |
||
6 | class JgfMultiGraph { |
||
7 | |||
8 | /** |
||
9 | * Constructor |
||
10 | * @param {string} type Multi graph classification. |
||
11 | * @param {string} label A text display for the multi graph. |
||
12 | * @param {object|null} metadata Custom multi graph metadata. |
||
13 | */ |
||
14 | constructor(type, label, metadata = null) { |
||
15 | this.type = type; |
||
16 | this.label = label; |
||
17 | this._metadata = metadata; |
||
18 | |||
19 | this._graphs = []; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Adds a single graph. |
||
24 | * @param {JgfGraph} graph Graph to be added. |
||
25 | */ |
||
26 | addGraph(graph) { |
||
27 | this._graphs.push(graph); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Returns all graphs. |
||
32 | */ |
||
33 | get graphs() { |
||
34 | return this._graphs; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Sets the multi graph meta data. |
||
39 | */ |
||
40 | set metadata(metadata) { |
||
41 | Guard.assertValidMetadata(metadata); |
||
42 | this._metadata = metadata; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Returns the multi graph meta data. |
||
47 | */ |
||
48 | get metadata() { |
||
49 | return this._metadata; |
||
50 | } |
||
51 | } |
||
52 | |||
55 | }; |